# Maintainer: psykose <alice@ayaya.dev>
pkgname=zrythm
pkgver=1.0.0_beta203
_pkgver=1.0.0-beta.2.0.3
pkgrel=3
_libbacktrace=208a7bace57141c54e1771ce0483275a225eb931
pkgdesc="Highly automated and intuitive digital audio workstation"
url="https://sr.ht/~alextee/zrythm/"
arch="aarch64 x86 x86_64" # lsp-dsp-lib, faust
license="AGPL-3.0-or-later"
depends="carla breeze-icons font-dseg lsp-dsp-lib"
makedepends="
	bash
	boost-dev
	carla-dev
	chromaprint-dev
	curl-dev
	faust-dev
	faust-tools
	fftw-dev
	flex-dev
	graphviz-dev
	gtk4.0-dev
	gtksourceview5-dev
	guile-dev
	help2man
	jack-dev
	json-glib-dev
	libadwaita-dev
	libaudec-dev
	libcyaml-dev
	libexecinfo-dev
	libsndfile-dev
	lilv-dev
	lsp-dsp-lib-dev
	meson
	pulseaudio-dev
	py3-sphinx
	reproc-dev
	rtmidi-dev
	rubberband-dev
	sassc
	vamp-sdk-dev
	xxhash-dev
	yaml-dev
	"
checkdepends="xvfb-run"
subpackages="
	$pkgname-doc
	$pkgname-lang
	$pkgname-bash-completion
	$pkgname-fish-completion:_fish
	$pkgname-dbg
	"
source="https://www.zrythm.org/releases/zrythm-$_pkgver.tar.xz
	libbacktrace_$_libbacktrace.tar.gz::https://github.com/alex-tee/libbacktrace/archive/$_libbacktrace.tar.gz
	execinfo.patch
	"
builddir="$srcdir/$pkgname-$_pkgver"
options="!check"

prepare() {
	default_prepare
	ln -sfv /usr/bin/sassc sass
	export PATH="$PATH:$PWD"

	ln -sfv "$srcdir"/libbacktrace-$_libbacktrace \
		subprojects/libbacktrace
}

build() {
	abuild-meson \
		-Dtests="$(want_check && echo true || echo false)" \
		-Dgui_tests="$(want_check && echo true || echo false)" \
		-Drtmidi=enabled \
		-Dopus=true \
		-Dcheck_updates=false \
		-Ddseg_font=false \
		-Db_lto=true \
		--buildtype=release \
		. output

	meson compile -C output
}

check() {
	xvfb-run -a meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	cd "$pkgdir"
	rm -rf usr/include
	rm -rf usr/lib/libbacktrace.a
}

_fish() {
	pkgdesc="Fish completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	amove usr/share/fish
}

sha512sums="
32d812156efeefa41132ec6e7b486053ecfa9462772e885823bc9c6bdc93f674dcb9414a977ef7ae849c17f87e45037103d745d01e54b9aacf475904de4fd820  zrythm-1.0.0-beta.2.0.3.tar.xz
41a4dc18cb90377858b63feddd55a1441a23c20067889f9cd5e9d3aeaa9dcb3661e7663a52129df0d01681126461f9fa76071a9a47a0c0aef0f2256f48cadb78  libbacktrace_208a7bace57141c54e1771ce0483275a225eb931.tar.gz
d541cbfb79bbb8f0f4d40a398f570d77f4cf08d5eacc1c54b36a130f0571f6a8514e2a4f91d4240126528cba419747bcb8a14694d4a2fb6a38cd77091447a1fd  execinfo.patch
"
